const util = require('../../utils/util.js')
const Monitor = require('../../utils/monitor.js').Monitor
Page(Monitor.hookApp({
  data: {
    imgUrl: getApp().globalData.imgUrl,
    imgUrls: getApp().globalData.imgUrls
  },
  jump(e) { //判断是不是黑卡  可跳到成长值
    let ev = e.currentTarget.dataset,
      idx = ev.idx,
      card_id = ev.card_id;
    if (ev.name == 'grow') { //如果点击已有会员成长值
      wx.navigateTo({
        url: `../VipGrow/VipGrow?card_id=${card_id}`,
      })
    } else if (ev.name == 'vip') { //如果点击已有会员卡
      util.API('spwx/v1.Vipcard/details', {
        card_id: card_id
      }).then(res => {
        wx.navigateTo({
          url: `../Vip/Vip?index=${idx}&stasus=true&card_id=${card_id}`,
        })
      })
    } else { //如果点击为拥有会员卡
      wx.navigateTo({
        url: `../Vip/Vip?index=${idx}&stasus=false&card_id=${card_id}`
      })
    }
  },

  onShow() {
    util.API('spwx/v1.Vipcard/cardBag').then(({code,data,msg}) => {
      if(code === 200){
        let {
          noRecieveCards,
          alreadyRecieveCards
        } = data
        this.setData({
          noRecieveCards,
          alreadyRecieveCards
        })
      }else{
        wx.showToast({
          title: msg + '',
          icon:'none'
        })
      }
    })
  }
}))